package bTree.LeetCode;

public class 搜索二维矩阵2 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m=matrix.length;
        int n=matrix[0].length;
        int i=0,j=n-1;
        while (i<m&&j>=0){
            int  path=matrix[i][j];
            if(path==target){
                return true;
            } else if (path<target) {
                i++;
            }else {
                j--;
            }
        }
        return false;
    }
}